
package Testing;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
public class Arrlist {

	public static void main (String [] args)
	{
/*		HashMap  mp1 = new HashMap() ;
*/		String[] headers= {"key1","key2"};//country	statename	City	Partner	stYear	enYear

/*		String[] value1= {"value11","value12"};//INDIA	Karnataka	Bangalore	Ingram micro india ltd.	FY 2011	FY 2012

		String[] value2= {"value21","value22"};
		String[] value3= {"value31","value32"};
*/
		
		String [][] Data = {{"value11","value12"},{"value21","value22"},{"value31","value32"}};
		Arrlist ar = new Arrlist();
		ar.resultset(headers, Data);
		/*mp1.put("key1", "Value11");
		mp1.put("key2", "Value21");
		
		HashMap  mp2 = new HashMap() ;
		mp2.put("key1", "Value12");
		mp2.put("key2", "Value22");
		
		Map<Integer,HashMap> map = new HashMap<Integer,HashMap>();
		map.put(1, mp1);
		map.put(2, mp2);
		*//*ArrayList<HashMap> al= new ArrayList();
		al.add(mp1);
		al.add(mp2);
		
		Iterator<HashMap> it = al.iterator();
		while(it.hasNext())
		{
			HashMap ele =it.next();
			System.out.println(ele.values());
			}*/
		
		//System.out.println(map.get(1));
		//System.out.println(map.get(2));
		
	}
	
	public List<Map<String,String>> resultset(Object headers[], Object Data [][])
	{
		/*int row = 3
		int col = 2;
		*/List<Map<String, String>> lst = new ArrayList<Map<String,String>>();
		for(int j=0;j<Data.length;j++){
			LinkedHashMap m1 = new LinkedHashMap ();
			Object [] val = Data[j];
			/*System.out.println("Data[j].length"+ Data[j].length);*/
		for(int i=0;i<Data[j].length;i++)
		{
			LinkedHashMap map = new LinkedHashMap ();
			m1.put(headers[i],val[i]);
		}
		lst.add(m1);
		}
		/*System.out.println("the value is "+lst.get(0).get("country"));		
		System.out.println("the value is "+lst.get(2).values());		
		System.out.println("the value is "+lst.get(0).keySet());*/		
		return lst;
	}
}
